from django.contrib import admin
from .models import Category, Food, Purchase

# Register your models here.

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    search_fields = ('name',)

@admin.register(Food)
class FoodAdmin(admin.ModelAdmin):
    list_display = ('name', 'category', 'quantity', 'unit', 'expiry_date', 'storage_location')
    list_filter = ('category', 'storage_location')
    search_fields = ('name',)
    date_hierarchy = 'expiry_date'

@admin.register(Purchase)
class PurchaseAdmin(admin.ModelAdmin):
    list_display = ('food', 'quantity', 'price', 'purchase_date')
    list_filter = ('purchase_date',)
    date_hierarchy = 'purchase_date'
